$(function () {
    // // 初始化计图片下标值数
    // count_index = 0;
    // // 初始化时钟
    // time_img1 = null;
    // time_ad1 = setInterval("showAd()", 2000);
    // time_ad2 = setInterval("autoClose()", 7000);
    // time_img1 = setInterval("rotaionImage()", 5000);
    // btnChange();
    // smallCircle();
    // imgButton();
    // onImage();
    // showPhone();
    // closeAd();
    // searchKeyWord();
    General();   //日用百货
    // showNav(); 
    showDiv();   //运动出行
    showQrCode();  // 智能家居
    showImageLine();  //电视影音
    showTVmovie();   //鼠标滑过产品切换
    showAI();   // 笔记本 平板
    showHeadset();   // 生活电器
    showparts();// 厨房电器
    // showPeriphery();
    // setInterval("hideFooterImage()", 3000);
    // scrollTop();
});


// banner切换
$(function () {
    function changeImg(num) {
        $(".img-box li").eq(num).fadeIn().siblings().fadeOut();
        $(".focus span").eq(num).addClass("content").siblings().removeClass("content");
    }

    var num = 0;
    //1、实现自动播放
    var timer = 0;
    function autoPlay() {
        timer =  setInterval(function () {
            num++;
            num = (num == 7 ? 0 : num);
            /*num = (num==7?0:num);*/
            changeImg(num)
        },3000)
    }
    autoPlay();
    $("#banner-con").mouseenter(function () {
        clearInterval(timer);
    }).mouseleave(function () {
        clearInterval(timer);
        autoPlay();
    })

    //4、点击左右的箭头，切换图片
    $("#banner-con .left").click(function () {
        num--;
        num = num == -1 ? 6 : num;
        changeImg(num);
    })
    $("#banner-con .right").click(function () {
        num++;
        num = num == 7 ? 0 : num;
        changeImg(num);
    })
    $("#banner-con .focus span").click(function () {
        num = $(this).index();
        changeImg(num);
    })
})

//鼠标滑过产品切换
function showTVmovie() {
    var $liElem = $("#main-box-chuandai .box-head .more-box li");
    $($liElem).each(function (index, element) {
        // console.log(element)
        $(element).mouseover(function () {
            if (index === 0) {
                var firstElem = "div#main-box-chuandai .product-list ul.brick-list:first";
                var secondElem = "div#main-box-chuandai .product-list ul.brick-list:last";
            } else {
                var firstElem = "div#main-box-chuandai .product-list ul.brick-list:last";
                var secondElem = "div#main-box-chuandai .product-list ul.brick-list:first";
            }
            $("div#main-box-chuandai .box-head .more-box .tab-active").attr("class", "");
            $(this).attr("class", "tab-active");
            $(firstElem).removeClass("hide");
            $(secondElem).addClass("hide");
        })
    })
}

// 笔记本 平板
function showAI() {
    var $liElem = $("#main-box-ipd .box-head .more-box li");
    $($liElem).each(function (index, element) {
        $(element).mouseover(function () {
            if (index === 0) {
                var firstElem = "div#main-box-ipd .product-list ul.brick-list:first";
                var secondElem = "div#main-box-ipd .product-list ul.brick-list:eq(1)";
                var thirdElem = "div#main-box-ipd .product-list ul.brick-list:last";
            } else if (index === 1) {
                var firstElem = "div#main-box-ipd .product-list ul.brick-list:eq(1)";
                var secondElem = "div#main-box-ipd .product-list ul.brick-list:first";
                var thirdElem = "div#main-box-ipd .product-list ul.brick-list:last";
            } else {
                var firstElem = "div#main-box-ipd .product-list ul.brick-list:last";
                var secondElem = "div#main-box-ipd .product-list ul.brick-list:eq(1)";
                var thirdElem = "div#main-box-ipd .product-list ul.brick-list:first";
            }
            $("div#main-box-ipd .box-head .more-box .tab-active").attr("class", "");
            $(this).attr("class", "tab-active");
            $(firstElem).removeClass("hide");
            $(secondElem).addClass("hide");
            $(thirdElem).addClass("hide");
        })
    })
}



//电视影音
function showImageLine() {
    var $liElem = $("#main-box-TV .box-head .more-box li");
    $($liElem).each(function (index, element) {
        // console.log(element)
        $(element).mouseover(function () {
            if (index === 0) {
                var firstElem = "div#main-box-TV .product-list ul.brick-list:first";
                var secondElem = "div#main-box-TV .product-list ul.brick-list:last";
            } else {
                var firstElem = "div#main-box-TV .product-list ul.brick-list:last";
                var secondElem = "div#main-box-TV .product-list ul.brick-list:first";
            }
            $("div#main-box-TV .box-head .more-box .tab-active").attr("class", "");
            $(this).attr("class", "tab-active");
            $(firstElem).removeClass("hide");
            $(secondElem).addClass("hide");
        })
    })
}



// 生活电器
function showHeadset() {
    var $liElem = $("#main-box-shenghuo .box-head .more-box li");
    $($liElem).each(function (index, element) {
        $(element).mouseover(function () {
            if (index === 0) {
                var firstElem = "div#main-box-shenghuo .product-list ul.brick-list:first";
                var secondElem = "div#main-box-shenghuo .product-list ul.brick-list:eq(1)";
                var thirdElem = "div#main-box-shenghuo .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-shenghuo .product-list ul.brick-list:last";
            } else if (index === 1) {
                var firstElem = "div#main-box-shenghuo .product-list ul.brick-list:eq(1)";
                var secondElem = "div#main-box-shenghuo .product-list ul.brick-list:first";
                var thirdElem = "div#main-box-shenghuo .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-shenghuo .product-list ul.brick-list:last";
            } else {
                var firstElem = "div#main-box-shenghuo .product-list ul.brick-list:last";
                var secondElem = "div#main-box-shenghuo .product-list ul.brick-list:eq(1)";
                var thirdElem = "div#main-box-shenghuo .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-shenghuo .product-list ul.brick-list:first";
            }
            $("div#main-box-shenghuo .box-head .more-box .tab-active").attr("class", "");
            $(this).attr("class", "tab-active");
            $(firstElem).removeClass("hide");
            $(secondElem).addClass("hide");
            $(thirdElem).addClass("hide");
            $(fourthElem).addClass("hide");
        })
    })
}



// 厨房电器
function showparts() {
    var $liElem = $("#main-box-kitchen .box-head .more-box li");
    $($liElem).each(function (index, element) {
        $(element).mouseover(function () {
            if (index === 0) {
                var firstElem = "div#main-box-kitchen .product-list ul.brick-list:first";
                var secondElem = "div#main-box-kitchen .product-list ul.brick-list:eq(1)";
                var thirdElem = "div#main-box-kitchen .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-kitchen .product-list ul.brick-list:last";
            } else if (index === 1) {
                var firstElem = "div#main-box-kitchen .product-list ul.brick-list:eq(1)";
                var secondElem = "div#main-box-kitchen .product-list ul.brick-list:first";
                var thirdElem = "div#main-box-kitchen .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-kitchen .product-list ul.brick-list:last";
            } else {
                var firstElem = "div#main-box-kitchen .product-list ul.brick-list:last";
                var secondElem = "div#main-box-kitchen .product-list ul.brick-list:eq(1)";
                var thirdElem = "div#main-box-kitchen .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-kitchen .product-list ul.brick-list:first";
            }
            $("div#main-box-kitchen .box-head .more-box .tab-active").attr("class", "");
            $(this).attr("class", "tab-active");
            $(firstElem).removeClass("hide");
            $(secondElem).addClass("hide");
            $(thirdElem).addClass("hide");
            $(fourthElem).addClass("hide");
        })
    })
}


// 智能家居
function showQrCode() {
    var $liElem = $("#main-box-home .box-head .more-box li");
    $($liElem).each(function (index, element) {
        $(element).mouseover(function () {
            if (index === 0) {
                var firstElem = "div#main-box-home .product-list ul.brick-list:first";
                var secondElem = "div#main-box-home .product-list ul.brick-list:eq(1)";
                var thirdElem = "div#main-box-home .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-home .product-list ul.brick-list:last";
            } else if (index === 1) {
                var firstElem = "div#main-box-home .product-list ul.brick-list:eq(1)";
                var secondElem = "div#main-box-home .product-list ul.brick-list:first";
                var thirdElem = "div#main-box-home .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-home .product-list ul.brick-list:last";
            } else {
                var firstElem = "div#main-box-home .product-list ul.brick-list:last";
                var secondElem = "div#main-box-home .product-list ul.brick-list:eq(1)";
                var thirdElem = "div#main-box-home .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-home .product-list ul.brick-list:first";
            }
            $("div#main-box-home .box-head .more-box .tab-active").attr("class", "");
            $(this).attr("class", "tab-active");
            $(firstElem).removeClass("hide");
            $(secondElem).addClass("hide");
            $(thirdElem).addClass("hide");
            $(fourthElem).addClass("hide");
        })
    })
}




//运动出行
function showDiv() {
    var $liElem = $("#main-box-motion .box-head .more-box li");
    $($liElem).each(function (index, element) {
        $(element).mouseover(function () {
            if (index === 0) {
                var firstElem = "div#main-box-motion .product-list ul.brick-list:first";
                var secondElem = "div#main-box-motion .product-list ul.brick-list:eq(1)";
                var thirdElem = "div#main-box-motion .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-motion .product-list ul.brick-list:last";
            } else if (index === 1) {
                var firstElem = "div#main-box-motion .product-list ul.brick-list:eq(1)";
                var secondElem = "div#main-box-motion .product-list ul.brick-list:first";
                var thirdElem = "div#main-box-motion .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-motion .product-list ul.brick-list:last";
            } else {
                var firstElem = "div#main-box-motion .product-list ul.brick-list:last";
                var secondElem = "div#main-box-motion .product-list ul.brick-list:eq(1)";
                var thirdElem = "div#main-box-motion .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-motion .product-list ul.brick-list:first";
            }
            $("div#main-box-motion .box-head .more-box .tab-active").attr("class", "");
            $(this).attr("class", "tab-active");
            $(firstElem).removeClass("hide");
            $(secondElem).addClass("hide");
            $(thirdElem).addClass("hide");
            $(fourthElem).addClass("hide");
        })
    })
}


//日用百货
function General() {
    var $liElem = $("#main-box-General .box-head .more-box li");
    $($liElem).each(function (index, element) {
        $(element).mouseover(function () {
            if (index === 0) {
                var firstElem = "div#main-box-General .product-list ul.brick-list:first";
                var secondElem = "div#main-box-General .product-list ul.brick-list:eq(1)";
                var thirdElem = "div#main-box-General .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-General .product-list ul.brick-list:last";
            } else if (index === 1) {
                var firstElem = "div#main-box-General .product-list ul.brick-list:eq(1)";
                var secondElem = "div#main-box-General .product-list ul.brick-list:first";
                var thirdElem = "div#main-box-General .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-General .product-list ul.brick-list:last";
            } else {
                var firstElem = "div#main-box-General .product-list ul.brick-list:last";
                var secondElem = "div#main-box-General .product-list ul.brick-list:eq(1)";
                var thirdElem = "div#main-box-General .product-list ul.brick-list:eq(2)";
                var fourthElem = "div#main-box-General .product-list ul.brick-list:first";
            }
            $("div#main-box-General .box-head .more-box .tab-active").attr("class", "");
            $(this).attr("class", "tab-active");
            $(firstElem).removeClass("hide");
            $(secondElem).addClass("hide");
            $(thirdElem).addClass("hide");
            $(fourthElem).addClass("hide");
        })
    })
}